package com.cloud.mall.test.controller;

import com.cloud.mall.result.GeneralResponse;
import com.cloud.mall.test.service.AccountService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author: 梁二东
 * @Date: 2024/12/15 11:55
 * @Description:
 **/
@RestController
@RequestMapping("/testuser")
public class UserController {

    @Resource
    private AccountService accountService;

    /**
     * 扣除用户金额
     *
     * @param userId
     * @param money
     * @return
     */
    @GetMapping("/debit")
    public GeneralResponse<Void> debit(@RequestParam("userId") String userId, @RequestParam("money") Integer money) {
        accountService.debit(userId, money);
        return GeneralResponse.success(null);
    }
}
